package com.hefei.hight.reflection;

import java.lang.reflect.Field;

/**
 * @author caizhengjun
 * @date 2020/9/5 11:10 上午
 */
public class Test04 {
    public static void main(String[] args) throws Exception {

        Class<?> clazz = Class.forName("com.hefei.hight.reflection.Person");

        Object person = clazz.newInstance();
        Field field = clazz.getDeclaredField("name");
        field.setAccessible(true);
        field.set(person, "蔡正峻");

        clazz.getMethod("sayHello").invoke(person);

    }
}
